$(function () {
	$("#list_on").click(function () {
		$("#pull_down").toggle();
		$("#stop").css("display", "none");
		$("#deploy").css("display", "block");
	})
	$(".down_list").click(function () {
		$(this).css("background", "#F0F0F0").siblings().css("background", "#fff");
		$("#list_on").text($(this).text());

	})
	//	$("#list_on").toggle(function() {
	//			$("#pull_down").hide();
	//			$("#box").removeClass(".tiaozhuang").addClass(".zhankai");
	//		},function() {
	//			$("#pull_down").show();
	//			$("#box").removeClass(".zhankai").addClass(".tiaozhuang");
	//		}
	//
	//	);
	//	$("#list_on").toggle(function() {
	//		$("#box").removeClass("#stop").addClass("#deploy");
	//	}, function() {
	//		$("#box").removeClass("#deploy").addClass("#stop");
	//	})

})

//上传照片
function imgChange(obj1, obj2) {
	var _img = document.querySelector(".add_list")
	// var clone_img = _img.cloneNode(false)
	//获取点击的文本框input
	var file = document.getElementById("file");
	//存放图片的父级元素
	var imgContainer = document.getElementsByClassName(obj1)[0];
	//	console.log(imgContainer)
	//获取的图片文件
	console.log(file)
	console.log(file.files)
	var fileList = file.files;
	//文本框的父级元素
	var input = document.getElementsByClassName(obj2)[0];
	//	console.log(input);
	var imgArr = [];
	//遍历获取到得图片文件
	//	for (var i = 0; i < fileList.length; i++) {
	var imgUrl = window.URL.createObjectURL(file.files[0]);
	imgArr.push(imgUrl);
	var img = document.createElement("img");
	img.setAttribute("src", imgArr[0]);
	img.setAttribute("class", "img_y")
	var imgAdd = document.createElement("div");
	//              imgAdd.setAttribute("class", "z_addImg");
	//              imgAdd.appendChild(img);
	$(".ipt_wrap").append(img);
	imgContainer.appendChild(imgAdd);

	// console.log(clone_img)
	$("#add_game").append("<div class=\'add_list\'>				<div class=\'container\'>			        <!--    照片添加    -->			        <div class=\'z_photo\'>			            <div class=\'z_file\'>			            	<div class=\'ipt_wrap\' style=\'width: 100%;height:100%;\'>			                	<input type=\'file\' name=\'file\' id=\'file\' value=\'\' accept=\'image/*\' multiple onchange=\'imgChange(\'z_photo\',\'z_file\');\' />			            	</div>			            </div>			        </div>			        <div class=\'z_mask\'>			            <div class=\'z_alert\'>			                <p>确定要删除这张图片吗？</p>			                <p>			                    <span class=\'z_cancel\'>取消</span>			                    <span class=\'z_sure\'>确定</span>			                </p>			            </div>			        </div>			    </div>				<div class=\'miaoshu_wrap\'>					<div class=\'add_title\'>						<span style=\'height:.2rem;line-height: .2rem;\'>添加照片描述</span>						<img class=\'ic_photo_miaoshu\' src=\'img/ic_photo-miaoshu.png\' />					</div>					<textarea name=\'info[neirong]\' id=\'neirong\' placeholder=\'可对照片进行描述哦...\' rows=\'5\'></textarea>				</div>			</div>")

	//	};
	imgRemove();
};
// 移除照片
function imgRemove() {
	var imgList = document.getElementsByClassName("ipt_wrap");
	var mask = document.getElementsByClassName("z_mask")[0];
	var cancel = document.getElementsByClassName("z_cancel")[0];
	var sure = document.getElementsByClassName("z_sure")[0];
	for (var j = 0; j < imgList.length; j++) {
		console.log(j)
		imgList[j].index = j;
		imgList[j].onclick = function (e) {
			if (window.event) { //阻止默认事件
				window.event.returnValue = false; //IE
			} else {
				e.preventDefault();
			}
			var t = this;
			console.log(this)
			console.log(t.children[1]);
			
			mask.style.display = "block";
			cancel.onclick = function () {
				mask.style.display = "none";
			};
			sure.onclick = function () {
				mask.style.display = "none";
				//				t.style.display = "none";
				//				parent.removeChild(parent.querySelector('.bad'));
				t.children[1].remove();

			};

		}
	};
};


function add_game() {
	var add_game = document.getElementById("add_game");
	for (var i = 0; i < add_game.length; i++) {

	}
}


//删除照片的时候克隆节点

$(function(){

})



